<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>用户登陆</title>
    <script src="/js/vue.js"></script>
    <script src="/js/vue-resource1.5.1"></script>
    <link href="style/style_log.css" rel="stylesheet" type="text/css">
</head>
<body class="login" mycollectionplug="bind">
<div id="app">
    <div class="login_m">
        <div class="login_boder">
            <div class="login_padding" id="login_model">
                <h2>用户名</h2>
                <label>
                    <input type="text" id="username" class="txt_input txt_input2" placeholder="输入账号" v-model="user.username">
                </label>
                <h2>密码</h2>
                <label>
                    <input type="password" name="textfield2" id="userpwd" class="txt_input" placeholder="******" v-model="user.password">
                </label>
                <p class="forgot"><a id="iforget" href="#">忘记密码</a></p>
                <div class="rem_sub">
                    <div class="rem_sub_l">
                        <input type="checkbox" name="checkbox" id="save_me">
                        <label for="save_me">记住我</label>
                    </div>
                    <label>
                        <input type="submit" class="sub_button" @click="login" name="button" id="button" value="登 陆"
                               style="opacity: 0.7;">
                    </label>
                </div>
            </div>

        </div>
    </div>
    <br> <br>
    <p align="center"> Copyright © 中移（成都）产业研究院</p>
</div>

<script>
    new Vue({
        el: '#app',
        data: {
            message: "第一个",
            test: "德勇",
            user: {username: "", password: ""}
        },
        created: function () {
        },
        methods: {
            login: function () {
                //发送get请求
                this.$http.post('/login', {"username": this.user.username, "password": this.user.password}).then(function (res) {
                    this.emps = res.body;
                    if (res.body.code == -500) {
                        alert(res.body.msg);
                    } else  {
                        this.set("loginUser", res.body, 1)
                        console.log(res.body);
                        window.location.href = "/index.html";
                    }
                }, function () {
                    console.log('请求失败处理');
                });
            },
            set: function (name, value, days) {
                var d = new Date;

                d.setTime(d.getTime() + 24*60*60*1000*days);

                window.document.cookie = name + "=" + JSON.stringify(value) + ";path=/;expires=" + d.toGMTString();

            },
            get: function (name) {
                var v = window.document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');

                return v ? v[2] : null;

            },
            delete: function (name) {
                this.set(name, '', -1);

            }
        }
    });
</script>

</body>
</html>